package word_queue;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import utils.RabbitMqUtils;

import java.io.IOException;

public class Provider {
    public static void main(String[] args) throws IOException {
        //获取连接对象
        Connection connection = RabbitMqUtils.getConnection();
        //获取通道对象
        Channel channel = connection.createChannel();
        //通过通道声明（创建）一个队列
        channel.queueDeclare("work", false, false, false, null);
        //发布（生产）消息
        for (int i = 1; i <=10 ; i++) {
            channel.basicPublish("", "work", null,
                    (i+"hello work-queue").getBytes() );
        }
        //关闭连接
        RabbitMqUtils.closeConnectionAndChannel(connection, channel);

    }
}
